class_name ConnectObj

var target_signal:Signal
var funcs:Array[Callable] = []

func _init(target_signal:Signal,funcs:Array[Callable] = [],auto_connect:bool = true) -> void:
	self.target_signal = target_signal
	self.funcs = funcs
	if auto_connect and funcs.size() > 0:
		connect_all()
func connect_single(f:Callable,connect_flag:int = 0):
	if not target_signal.is_connected(f):
		funcs.append(f)
		target_signal.connect(f,connect_flag)
func disconnect_single(f:Callable):
	if target_signal.is_connected(f):
		funcs.erase(f)
		target_signal.disconnect(f)
func connect_all(connect_flag:int = 0):
	for f in funcs:
		connect_single(f,connect_flag)
func disconnect_all():
	for f in funcs:
		disconnect_single(f)
